import React, { useEffect, useState } from 'react';
import ScrollView from './ScrollView';
const list = [
  {
    name: 'zhangsan',
    age: 23,
  },
  {
    name: 'zhangsan',
    age: 23,
  },
];
export default function () {
  const [data, setData] = useState({ list: [], pageCount: 15 }); /* 记录列表数据 */
  /* 请求数据 */
  const getData = async () => {
    if (data.list.length >= data.pageCount) return console.log('没有数据了～');
    setData({
      ...data,
      list: data.list.concat(list),
    });
  };
  /* 滚动到底部触发 */
  const handerScrolltolower = () => {
    console.log('scroll已经到底部');
    getData();
  };
  /* 初始化请求数据 */
  useEffect(() => {
    getData();
  }, []);
  return <ScrollView list={data.list} scrollToBottom={handerScrolltolower} scroll={() => {}} />;
}
